import pandas as pd


def read_genepred(gpe_file: str) -> pd.DataFrame:
    gpes = pd.read_csv(gpe_file, header=None, delimiter='\t', compression='infer', usecols=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12])
    gpes.columns = pd.Index(['Transcript', 'Chrom', 'Strand', 'TxStart', 'TxEnd', 'CDSStart', 'CDSEnd', 'ExonCount', 'ExonStarts', 'ExonEnds', 'Gene'])
    gpes['CDSLength'] = gpes.apply(lambda x: x.CDSEnd - x.CDSStart, axis=1)
    gpes['Key'] = gpes.apply(lambda x: f'{x.Chrom}:{x.Gene}:{x.Transcript}', axis=1)
    return gpes


def read_bed(bed_file: str) -> pd.DataFrame:
    beds = pd.read_csv(bed_file, header=None, delimiter='\t', compression='infer')
    if beds.shape[1] == 4:
        beds.columns = pd.Index(['Chrom', 'Start', 'End', 'Name'])
    else:
        beds.columns = pd.Index(['Chrom', 'Start', 'End'])
        beds['Name'] = beds.apply(lambda x: f'{x.Chrom}:{x.Start}-{x.End}', axis=1)
    return beds
